package com.famid.flashcards.animation;

import com.famid.flashcards.FlashCard;

import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;

public final class SwapViews implements Runnable {
	private boolean mIsFirstView;
	FlashCard card;

	public SwapViews(boolean isFirstView, FlashCard card) {
		mIsFirstView = isFirstView;
		this.card = card;
//		this.card2 = card2;
	}

	public void run() {
		final float centerX = card.getWidth() / 2.0f;
		final float centerY = card.getHeight() / 2.0f;
		Flip3dAnimation rotation;

		if (mIsFirstView) {
			rotation = new Flip3dAnimation(-90, 0, centerX, centerY);
		} else {

			rotation = new Flip3dAnimation(90, 0, centerX, centerY);
		}

		rotation.setDuration(500);
		rotation.setFillAfter(true);
		rotation.setInterpolator(new DecelerateInterpolator());

		if (mIsFirstView) {
			card.startAnimation(rotation);
			card.setShowQuestion(!true);
		} else {
			card.startAnimation(rotation);
			card.setShowQuestion(!false);
		}
	}
}
